package com.example.controller;

import com.example.entity.po.Information;
import com.example.service.InformationService;
import com.example.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class InformationController {
    @Autowired
    private InformationService informationService;

    @GetMapping("/queryInformation")
    public ResultUtils queryInformation(){
        List<Information> list=informationService.queryInformation();
        if (list.size()==0){
            return ResultUtils.Failure("查询基本信息失败",null);
        }else {
            return ResultUtils.Successful("查询基本信息成功",list);
        }
    }

    @PostMapping("/updateInformation")
    public ResultUtils updateInformation(@RequestBody Information information){
        int res=informationService.updateInformation(information);
        if (res==0){
            return ResultUtils.Failure("修改基本信息失败",null);
        }else {
            return ResultUtils.Successful("修改基本信息成功",null);
        }
    }
}
